/**
 * 功能描述
 */

define(function (require, exports, module) {
	var Form = require("form");
	var store =require("store");
	var activeUser = store.get("user");
	var Dialog = require("dialog");
	var scatterCheckInBiz = require("../business/scatterCheckInBiz");
	
    var instance = {
        initComponent: function (widget) {
        	var tempGridRowData = widget.get("tempGridRowData"),
        		nonMemberType = scatterCheckInBiz.nonMemberTypeS(tempGridRowData,widget);
        	var items = [];
        	if(tempGridRowData && tempGridRowData.nonMemGroupReserve && 
        			tempGridRowData.nonMemGroupReserve.nonMemberGroup.signUpType && 
        				tempGridRowData.nonMemGroupReserve.nonMemberGroup.signUpType.key == "Experience"){
        		items.push({
	        		name: "signUpType",
					label: "入住类型",
					type:"select",
					options: [{
		                key: "Experience",
		                value: "体验散客"
		            }],
		            readonly:true,
		            validate: ["required"]
        		});
        	}else{
        		items.push({
    				name: "tourType",
    				label: "入住类型",
    				type:"select",
    				validate: ["required"],
    				options: [{
    	                key: "IndivMember",
    	                value: "会员散客"
    	            }, {
    	                key: "TravelGroup",
    	                value: "旅游团队"
    	            }, {
    	                key: "Individual",
    	                value: "旅游散客"
    	            }],
    			});
        	}
        	items.push({
				name:"pledge",
				label:"入住押金",
				exValidate: function(value) {
                    if(!isNaN(value) && parseFloat(value).toFixed(2) > 0){
                    	return true;
               		 } else{
               			return "入住押金必须输入数字且不能为负！";
               		 }
                }
			});
        	if(nonMemberType){
        		items.push({
        			name:"money",
        			label:"已收取预约订金",
        			readonly:true
        		})
        	};
        	items.push({
				name:"operateDate",
				label:"登记日期",
				type:"date",
				mode:"YYYY-MM-DD",
				defaultValue:moment().format("YYYY-MM-DD"),
				readonly:true,
			},{
				name:"operator",
				label:"登记人",
				readonly:true,
				defaultValue:activeUser.name
			},{
				name:"pkOperator",
				type:"hidden",
				defaultValue: activeUser.pkUser
			});
        	var formEnd = new Form({
    			parentNode: ".J-formEnd",
    			model: {
    				id: "formEnd",
    				layout: "2_1",
    				defaultButton: false,
    				items: items
    			}
    		});
        	widget.set("formEnd",formEnd);
        }
    };
    module.exports = instance;
});
